package com.example;
 
import org.example.spring.AnnotationConfigApplicationContext;

import com.example.service.UserService;
 
/**
 * @author heyunlin
 * @version 1.0
 */
public class ScopeExample {
 
    public static void main(String[] args) throws ClassNotFoundException {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfig.class);
 
        System.out.println("----------------------------------------------------");
 
        Object userMapper1 = applicationContext.getBean("userMapper");
        Object userMapper2 = applicationContext.getBean("userMapper");
 
        System.out.println(userMapper1);
        System.out.println(userMapper2);
 
        System.out.println("----------------------------------------------------");
 
        Object userService1 = applicationContext.getBean("userService");
        Object userService2 = applicationContext.getBean("userService");
 
        System.out.println(userService1);
        System.out.println(userService2);
        
        System.out.println("----------------------------------------------------");
 
        Object userController1 = applicationContext.getBean("userController");
        Object userController2 = applicationContext.getBean("userController");
 
        
        System.out.println(userController1);
        System.out.println(userController2);
        
        UserService userService = (UserService)applicationContext.getBean("userService");
        System.out.println(userService.getUserMapper());
    }
 
}